home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / security / log_tcp_6.0alpha.shar / README < prev    next >
Encoding:
Text File  |  1993-07-02  |  35.6 KB  |  787 lines

  1. @(#) README 1.11 93/07/02 16:33:20
  2.  
  3. Table of contents
  4. -----------------
  5.  
  6.     1 - Introduction
  7.     2 - Disclaimer
  8.     3 - Tutorials
  9.         3.1 - How it works
  10.         3.2 - Where the logging information goes
  11.     4 - Features
  12.         4.1 - Access control
  13.         4.2 - Host name spoofing
  14.         4.3 - Host address spoofing
  15.         4.4 - Remote username lookups
  16.         4.5 - Language extension hooks
  17.     5 - Other works
  18.         5.1 - Related documents
  19.         5.2 - Related software
  20.     6 - Limitations
  21.         6.1 - Known wrapper limitations
  22.         6.2 - Known system software bugs
  23.     7 - Configuration and installation
  24.         7.1 - Easy configuration and installation
  25.         7.2 - Advanced configuration and installation
  26.         7.3 - Daemons with arbitrary path names
  27.         7.4 - Building and testing the access control rules
  28.         7.5 - Other applications
  29.     8 - Acknowledgements
  30.  
  31. 1 - Introduction
  32. ----------------
  33.  
  34. With this package you can monitor incoming connections to the SYSTAT,
  35. FINGER, FTP, TELNET, RLOGIN, RSH, EXEC, TFTP, TALK, and other network
  36. services. 
  37.  
  38. It supports both 4.3BSD-style sockets and System V.4-style TLI. Praise
  39. yourself lucky if you don't know what that means.
  40.  
  41. The package provides tiny daemon wrapper programs that can be installed
  42. without any changes to existing software or to existing configuration
  43. files.  The wrappers report the name of the remote host and of the
  44. requested service; the wrappers do not exchange information with the
  45. remote client process, and impose no overhead on the actual
  46. communication between the client and server applications.
  47.  
  48. Optional features are: access control to restrict what systems can
  49. connect to your network daemons; remote user name lookups with the RFC
  50. 931 protocol; additional protection against hosts that pretend to have
  51. someone elses host name; additional protection against hosts that
  52. pretend to have someone elses host address.
  53.  
  54. Early versions of the programs were tested with Ultrix >= 2.2, with
  55. SunOS >= 3.4 and ISC 2.2. Later versions have been installed on a wide
  56. variety of platforms such as SunOS 4.x and 5.x, Ultrix 3.x and 4.x, DEC
  57. OSF/1 T1.2-2, HP-UX 8.x, AIX 3.1.5, Apollo SR10.3.5, Sony, NeXT, SCO
  58. UNIX, DG/UX, Cray, and an unknown number of other ones.
  59.  
  60. Requirements are that the network daemons are spawned by a super server
  61. such as the inetd; a 4.3BSD-style socket programming interface and/or
  62. System V.4-style TLI programming interface; and the availability of a
  63. syslog(3) library and of a syslogd(8) daemon.  The wrappers should run
  64. without modification on any system that satisfies these requirements.
  65. Workarounds have been implemented for several common bugs in systems
  66. software.
  67.  
  68. What to do if this is your first encounter with the wrapper programs:
  69. 1) read the tutorial sections for an introduction to the relevant
  70. concepts and terminology; 2) glance over the security feature sections
  71. in this document; 3) follow the installation instructions (easy or
  72. advanced). I recommend that you first use the default security feature
  73. settings.  Run the wrappers for a few days to become familiar with
  74. their logs, before doing anything drastic such as cutting off access or
  75. installing booby traps.
  76.  
  77. 2 - Disclaimer
  78. --------------
  79.  
  80. The wrapper programs rely on source address information obtained from
  81. network packets. Such information is not 100 percent reliable, although
  82. the wrappers do their best to expose forgeries.
  83.  
  84. In the absence of cryptographic protection of message contents, and of
  85. cryptographic authentication of message originators, all data from the
  86. network should be treated with sound scepticism.
  87.  
  88. THIS RESTRICTION IS BY NO MEANS SPECIFIC TO THE TCP/IP PROTOCOLS.
  89.  
  90. 3 - Tutorials
  91. -------------
  92.  
  93. The tutorial sections give a gentle introduction to the operation of
  94. the wrapper programs, and introduce some of the terminology that is
  95. used in the remainder of the document: client, server, the inetd and
  96. syslogd daemons, and their configuration files.
  97.  
  98. 3.1 - How it works
  99. ------------------
  100.  
  101. Almost every application of the TCP/IP protocols is based on a client-
  102. server model. For example, when a user invokes the telnet command to
  103. connect to one of your systems, a telnet server process is executed on
  104. the target host. The telnet server process connects the user to a login
  105. process. A few examples of client and server programs are shown in the
  106. table below:
  107.  
  108.               client   server    application
  109.               --------------------------------
  110.               telnet   telnetd   remote login
  111.               ftp      ftpd      file transfer
  112.               finger   fingerd   show users
  113.  
  114. The usual approach is to run one single daemon process that waits for
  115. all kinds of incoming network connections. Whenever a connection is
  116. established, this daemon (usually called inetd) runs the appropriate
  117. server program and goes back to sleep, waiting for other connections.
  118.  
  119. The wrapper programs rely on a simple, but powerful mechanism.  Instead
  120. of directly running the desired server program, the inetd is tricked
  121. into running a small wrapper program. The wrapper logs the remote host
  122. name or address and performs some additional checks.  When all is well,
  123. the wrapper executes the desired server program and goes away.
  124.  
  125. The wrapper programs have no interaction with the remote user (or
  126. client process).  This has two major advantages: 1) the wrappers are
  127. application-independent, so that the same program can protect many
  128. kinds of network services; 2) no interaction also means that the
  129. wrappers are invisible from outside (at least for regular users).
  130.  
  131. Another important property is that the wrapper programs are active only
  132. when the initial contact between client and server is established. Once
  133. a wrapper has done its work there is no overhead on the client-server
  134. communication.
  135.  
  136. The simple mechanism has one major drawback: since the wrappers go away
  137. after the initial contact between client and server processes, the
  138. wrappers are of little use with network daemons that service more than
  139. one client.  The wrappers would only see the first client attempt to
  140. contact such a server. The NFS mount daemon is a typical example of
  141. a daemon that services requests from multiple clients.
  142.  
  143. There are two ways to use the wrapper programs:
  144.  
  145. 1) The easy way: move network daemons to some other directory and fill
  146.    the resulting holes with copies of the wrapper programs.  This
  147.    approach involves no changes to configuration files, so there is
  148.    very little risk of breaking things.
  149.  
  150. 2) The advanced way: leave the network daemons alone and modify the
  151.    inetd configuration file.  For example, an entry such as:
  152.  
  153.      tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
  154.  
  155.    When a tftp request arrives, inetd will run the wrapper program
  156.    (tcpd) with a process name `in.tftpd'.  This is the name that the
  157.    wrapper will use when logging the request and when scanning the
  158.    optional access control tables.  `in.tftpd' is also the name of the
  159.    server program that the wrapper will attempt to run when all is
  160.    well.  Any arguments (`-s /tftpboot' in this particular example) are
  161.    transparently passed on to the server program.
  162.  
  163. For an account of the history of the wrapper programs, with real-life
  164. examples, see the section below on related documents.
  165.  
  166. 3.2 - Where the logging information goes
  167. ----------------------------------------
  168.  
  169. The wrapper programs send their logging information to the syslog
  170. daemon (syslogd). The disposition of the wrapper logs is determined by
  171. the syslog configuration file (usually /etc/syslog.conf). Messages are
  172. written to files, to the console, or are forwarded to a @loghost.
  173.  
  174. Older syslog implementations (still found on Ultrix systems) only
  175. support priority levels ranging from 9 (debug-level messages) to 0
  176. (alerts). All logging information of the same priority level (or more
  177. urgent) is written to the same destination.  In the syslog.conf file,
  178. priority levels are specified in numerical form.  For example,
  179.  
  180.     8/usr/spool/mqueue/syslog
  181.  
  182. causes all messages with priority 8 (informational messages), and
  183. anything that is more urgent, to be appended to the file
  184. /usr/spool/mqueue/syslog.
  185.  
  186. Newer syslog implementations support message classes in addition to
  187. priority levels.  Examples of message classes are: mail, daemon, auth
  188. and news. In the syslog.conf file, priority levels are specified with
  189. symbolic names: debug, info, notice, ..., emerg. For example,
  190.  
  191.     mail.debug            /var/log/syslog
  192.  
  193. causes all messages of class mail with priority debug (or more urgent)
  194. to be appended to the /var/log/syslog file.
  195.  
  196. By default, the wrapper logs go to the same place as the transaction
  197. logs of the sendmail daemon. The disposition can be changed by editing
  198. the Makefile and/or the syslog.conf file. Send a `kill -HUP' to the
  199. syslogd after changing its configuration file. Remember that syslogd,
  200. just like sendmail, insists on one or more TABs between the left-hand
  201. side and the right-hand side expressions in its configuration file.
  202.  
  203. 4 - Features
  204. ------------
  205.  
  206. 4.1 - Access control
  207. --------------------
  208.  
  209. When compiled with -DHOSTS_ACCESS, the wrapper programs support a
  210. simple form of access control.  Access can be controlled per host, per
  211. service, or combinations thereof. The software provides hooks for the
  212. execution of shell commands when an access control rule fires; this
  213. feature may be used to install "booby traps".  For details, see the
  214. hosts_access.5 manual page, which is in `nroff -man' format. A later
  215. section describes how you can test your access control rules.
  216.  
  217. Access control is enabled by default. It can be turned off by editing
  218. the Makefile, or by providing no access control tables. The install
  219. instructions below describe the Makefile editing process.
  220.  
  221. When TCP/IP or UDP/IP is used underneath TLI, the wrapper programs
  222. provide the same functions as with socket-based applications. When some
  223. other protocol is used underneath TLI, the host address will be some
  224. universal magic cookie that may not be usable for access control
  225. purposes.
  226.  
  227. 4.2 - Host name spoofing
  228. ------------------------
  229.  
  230. With some network applications, such as RSH or RLOGIN, the remote host
  231. name plays an important role in the authentication process. Host name
  232. information can be reliable when lookups are done from a _local_ hosts
  233. table, provided that the client IP address can be trusted.
  234.  
  235. With _distributed_ name services, authentication schemes that rely on
  236. host names become more problematic. The security of your system now may
  237. depend on some far-away DNS (domain name server) outside your own
  238. control. Paradoxically, running NIS (YP) can actually improve hostname
  239. security because it provides you with the equivalent of a local hosts
  240. file.
  241.  
  242. The wrapper programs verify the remote host name that is returned by
  243. the address->name DNS server, by asking for a second opinion.  To this
  244. end, the programs look at the name and addresses that are returned by
  245. the name->address DNS server. If any discrepancies are found, the
  246. wrappers conclude that at least one of the two name servers is lying,
  247. and assume that they are dealing with a host that pretends to have
  248. someone elses host name.
  249.  
  250. When the wrappers are unable to verify the remote host name (the
  251. address->name lookup succeeds but the name->address lookup fails), they
  252. also assume that the host name is wrong. 
  253.  
  254. When the remote host name is unavailable (the address->name lookup
  255. fails) the wrappers just use the remote host address when logging the
  256. connection and when consulting the optional access control tables.
  257.  
  258. When the sources are compiled with -DPARANOID, the wrappers will drop
  259. the connection in case of a host name/address mismatch. When the
  260. sources are not compiled with -DPARANOID, the wrappers just pretend
  261. that the host name is unknown when logging the connection and when
  262. consulting the optional access control tables.
  263.  
  264. Paranoid mode is enabled by default. It can be turned off by editing
  265. the Makefile. The configuration and installation below describes the
  266. Makefile editing process.
  267.  
  268. 4.3 - Host address spoofing
  269. ---------------------------
  270.  
  271. While host name spoofing can be found out by asking a second opinion,
  272. it is much harder to find out that a host claims to have someone elses
  273. network address. And since host names are deduced from network
  274. addresses, address spoofing is at least as effective as name spoofing.
  275.  
  276. The wrapper programs can give additional protection against hosts that
  277. claim to have an address that lies outside their own network.  For
  278. example, some far-away host that claims to be a trusted host within
  279. your own network. Such things are possible even while the impersonated
  280. system is up and running.
  281.  
  282. This additional protection is not an invention of my own; it has been
  283. present for at least five years in the BSD rsh and rlogin daemons.
  284. Unfortunately, that feature was added *after* 4.3 BSD came out, so that
  285. very few, if any, UNIX vendors have adopted it.  Our site, and many
  286. other ones, has been running these enhanced daemons for several years,
  287. and without any ill effects.
  288.  
  289. When the programs are compiled with -DKILL_IP_OPTIONS, source routing
  290. will be disabled for all TCP connections that are handled by the
  291. wrapper programs.
  292.  
  293. All this cannot be used with SunOS 4.x because of a kernel bug in the
  294. implementation of the getsockopt() system call. Kernel panics have been
  295. reported for SunOS 4.1.1 and SunOS 4.1.2. The symptoms are "BAD TRAP"
  296. and "Data fault" while executing the tcp_ctloutput() kernel function.
  297.  
  298. The feature is disabled by default. It can be turned on by editing the
  299. Makefile.  The configuration and installation section below describes
  300. the Makefile editing process.
  301.  
  302. UDP services do not benefit from this additional protection. With UDP,
  303. all you can be certain of is the network packet's destination address.
  304.  
  305. 4.4 - Remote username lookups
  306. -----------------------------
  307.  
  308. The protocol proposed in RFC 931 provides a means to get the remote
  309. user name from the client host.  The requirement is that the client
  310. host runs an RFC 931-compliant daemon. The information provided by such
  311. a daemon is not intended to be used for authentication purposes, but it
  312. can provide additional information about the owner of a TCP connection.
  313.  
  314. Remote user name lookups are enabled when the wrappers are compiled
  315. with -DRFC931.  There are some limitations: the number of hosts that
  316. run an RFC 931 (or compatible) daemon is small (but growing); remote
  317. user name lookups do not work for datagram (UDP) connections. More
  318. seriously, remote user name lookups can cause noticeable delays with
  319. connections from non-UNIX PCs. The wrappers use a 30-second timeout for
  320. RFC931 lookups, to accommodate slow networks and slow hosts. 
  321.  
  322. By default, remote username lookups are not enabled. You can enable
  323. them by editing the Makefile. The remote username lookup timeout period
  324. (30 seconds default) can also be changed by editing the Makefile. The
  325. installation sections below describe the Makefile editing process.
  326.  
  327. The RFC 931 protocol has diverged into different directions (IDENT and
  328. TAP). To add to the confusion, both protocols use the same network
  329. port.  The daemon wrappers implement a common subset of the protocols.
  330.  
  331. With TLI-based network services, remote username lookups will be
  332. possible only when TCP/IP is the underlying network protocol.
  333.  
  334. 4.5 - Language extension hooks
  335. ------------------------------
  336.  
  337. The wrappers sport only a limited number of features. This is for a
  338. good reason: programs that are run at high privilege levels must be
  339. easy to verify.
  340.  
  341. However, some sites have very specific needs.  The options.c file
  342. provides a framework for adding extensions to the access control
  343. language. It comes with sample extensions that:  (1) switch to another
  344. user or group id; (2) perform remote user name lookups; (3) run an
  345. alternate server program (this allows you to produce customized bounce
  346. messages or to do really nasty stuff); (4) set arbitrary environment
  347. variables; (5) change the default file protection mask.
  348.  
  349. The language extension hook is not enabled by default because it
  350. introduces an incompatible change to the access control language
  351. syntax. Instructions to enable the extensions are given in the
  352. Makefile.
  353.  
  354. 5 - Other works
  355. ---------------
  356.  
  357. 5.1 - Related documents
  358. -----------------------
  359.  
  360. The war story behind the wrapper tools is described in:
  361.  
  362.     W.Z. Venema, "TCP WRAPPER, network monitoring, access control and
  363.     booby traps", UNIX Security Symposium III Proceedings (Baltimore),
  364.     September 1992. 
  365.  
  366.     ftp.win.tue.nl:/pub/security/tcp_wrapper.ps.Z (postscript)
  367.     ftp.win.tue.nl:/pub/security/tcp_wrapper.txt.Z (flat text)
  368.  
  369. The same cracker is also described in:
  370.  
  371.     W.R. Cheswick, "An Evening with Berferd, In Which a Cracker is
  372.     Lured, Endured, and Studied", Proceedings of the Winter USENIX
  373.     Conference (San Francisco), January 1992.
  374.  
  375.     research.att.com:/dist/internet_security/berferd.ps
  376.  
  377. 5.2 - Related software
  378. ----------------------
  379.  
  380. Network daemons etc. with enhanced logging capabilities can generate
  381. massive amounts of information: our 100+ workstations generate several
  382. hundred kbytes each day. egrep-based filters can help to suppress some
  383. of the noise.  A more powerful tool is the Swatch monitoring system by
  384. Stephen E. Hansen and E. Todd Atkins. Swatch can process log files in
  385. real time and can associate arbitrary actions with patterns; its
  386. applications are by no means restricted to security.  Swatch is
  387. available from sierra.stanford.edu, directory /pub/sources.
  388.  
  389. Socks, described in the UNIX Security III proceedings, can be used to
  390. control network traffic from hosts on an internal network, through a
  391. firewall host, to the outer world. Socks consists of a daemon that is
  392. run on the firewall host, and of a library with routines that redirect
  393. application socket calls through the firewall daemon.  Socks is
  394. available from s1.gov in /pub/socks.tar.Z.
  395.  
  396. Tcpr is a set of perl scripts by Paul Ziemba that enable you to run ftp
  397. and telnet commands across a firewall. Unlike socks it can be used with
  398. unmodified client software. Available from ftp.alantec.com, pub/tcpr.
  399.  
  400. Versions of rshd and rlogind, modified to report the remote user name
  401. in addition to the remote host name, are available for anonymous ftp
  402. (ftp.win.tue.nl:/pub/security/logdaemon-2.tar.Z).  These programs are
  403. drop-in replacements for SunOS 4.x, Ultrix 4.x, and SunOS 5.x.
  404.  
  405. The securelib shared library by William LeFebvre can be used to control
  406. access to network daemons that are not run under control of the inetd
  407. or that serve more than one client, such as the NFS mount daemon that
  408. runs until the machine goes down.  Available from eecs.nwu.edu, file
  409. /pub/securelib.tar.
  410.  
  411. xinetd (posted to comp.sources.unix) is an inetd replacement program
  412. that provides, among others, logging, username lookup and access
  413. control. However, it does not support TLI services, and it is only six
  414. times as much source code as the daemon wrapper programs.
  415.  
  416. Where shared libraries or router-based packet filtering are not an
  417. option, an alternative portmap daemon can help to improve RPC security,
  418. in particular that of NFS and of the NIS (YP) information service.
  419. ftp.win.tue.nl:/pub/security/portmap.shar.Z was tested with SunOS 4.1.1
  420. and 4.1.2, Ultrix 3.0 and Ultrix 4.x, HP-UX 8.x and AIX. The protection
  421. is less effective than that of the securelib library because portmap is
  422. mostly a dictionary service.  SunOS 4.x users should install the latest
  423. revision of the portmap and NIS daemons instead, or adopt NIS+ which
  424. has access control built in.
  425.  
  426. Source for a portable RFC 931 (TAP, IDENT)-compatible daemon by Peter
  427. Eriksson is available from ftp.lysator.liu.se:/pub/ident/servers.
  428.  
  429. Some TCP/IP implementations come without syslog library. Some come with
  430. the library but have no syslog daemon. A replacement can be found in
  431. ftp.win.tue.nl:/pub/security/surrogate-syslog.tar.Z.  The fakesyslog
  432. library that comes with the nntp sources reportedly works well, too.
  433.  
  434. 6 - Limitations
  435. ---------------
  436.  
  437. 6.1 - Known wrapper limitations
  438. -------------------------------
  439.  
  440. Some UDP (and rpc/udp) daemons linger around for a while after they
  441. have serviced a request, just in case another request comes in.  In the
  442. inetd configuration file these daemons are registered with the `wait'
  443. option. Only the request that started such a daemon will be seen by the
  444. wrappers.  Such daemons are better protected with the securelib shared
  445. library (see: Related software).
  446.  
  447. The wrappers do not work with RPC services over TCP. These services are
  448. registered as rpc/tcp in the inetd configuration file. The only non-
  449. trivial service that is affected by this limitation is rexd, which is
  450. used by the on(1) command. This is no great loss.  On most systems,
  451. rexd is less secure than a wildcard in /etc/hosts.equiv.
  452.  
  453. RPC broadcast requests (for example: rwall, rup, rusers) always appear
  454. to come from the responding host. What happens is that the client
  455. broadcasts its request to all portmap daemons on its network; each
  456. portmap daemon forwards the request to its own system. As far as the
  457. rwall etc.  daemons know, the request comes from the local host.
  458.  
  459. Portmap and RPC (e.g. NIS and NFS) (in)security is a topic in itself.
  460. See the section in this document on related software.
  461.  
  462. 6.2 - Known system software bugs
  463. --------------------------------
  464.  
  465. Workarounds have been implemented for several bugs in system software.
  466. They are described in the Makefile. Unfortunately, some system software
  467. bugs cannot be worked around. The result is loss of functionality.
  468.  
  469. Older ConvexOS versions come with a broken recvfrom(2) implementation.
  470. This makes it impossible for the daemon wrappers to look up the
  471. remote host address (and hence, the name) in case of UDP requests.
  472. A patch is available for ConvexOS 10.1; later releases should be OK.
  473.  
  474. On some systems, the optional RFC 931 remote username lookups may
  475. trigger a kernel bug.  When a client host connects to your system, and
  476. the RFC 931 connection from your system to that client is rejected by a
  477. router, your kernel may drop all connections with that client.  This is
  478. not a bug in the wrapper programs: complain to your vendor, and don't
  479. enable remote user name lookups until the bug has been fixed.
  480.  
  481. Reportedly, SunOS 4.1.1, Next 2.0a, ISC 3.0 with TCP 1.3, and AIX 3.2.2
  482. are OK.
  483.  
  484. Sony News/OS 4.51, HP-UX 8-something and Ultrix 4.3 still have the bug.
  485. At the time of writing, a fix for Ultrix is being field tested (CXO-8919).
  486.  
  487. The following procedure can be used (from outside the tue.nl domain) to
  488. find out if your kernel has the bug. From the system under test, do:
  489.  
  490.     % ftp 131.155.70.100
  491.  
  492. This command attempts to make an ftp connection to our anonymous ftp
  493. server (ftp.win.tue.nl).  When the connection has been established, run
  494. the following command from the same system under test, while keeping
  495. the ftp connection open:
  496.  
  497.     % telnet 131.155.70.100 111
  498.  
  499. Do not forget the `111' at the end of the command. This telnet command
  500. attempts to connect to our portmap process.  The telnet command should
  501. fail with:  "host not reachable", or something like that. If your ftp
  502. connection gets messed up, you have the bug. If the telnet command does
  503. not fail, please let me know a.s.a.p.!
  504.  
  505. For those who care, the bug is that the BSD kernel code was not careful
  506. enough with incoming ICMP UNREACHABLE control messages (it ignored the
  507. local and remote port numbers). The bug is still present in the BSD
  508. NET/1 source release (1989) but apparently has been fixed in BSD NET/2
  509. (1991). You can see it with your own eyes, if you have the courage.
  510.  
  511. 7 - Configuration and installation
  512. ----------------------------------
  513.  
  514. 7.1 - Easy configuration and installation
  515. -----------------------------------------
  516.  
  517. The "easy" recipe requires no changes to existing software or
  518. configuration files.  Basically, you move the daemons that you want to
  519. protect to a different directory and plug the resulting holes with
  520. copies of the wrapper programs.
  521.  
  522. If you don't run Ultrix, you won't need the miscd wrapper program.  The
  523. miscd daemon implements among others the SYSTAT service, which produces
  524. the same output as the the WHO command.
  525.  
  526. Copy the file Makefile.dist to Makefile, edit the Makefile according to
  527. the instructions at the beginning of that file, and type `make'. 
  528.  
  529. When the `make' succeeds the result is two executables (maybe three in
  530. case of Ultrix). The `try' program can be used to play with host access
  531. control tables and is described in a later section.
  532.  
  533. The tcpd program can be used to monitor the telnet, finger, ftp, exec,
  534. rsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
  535. a one-to-one mapping onto executable files.
  536.  
  537. The tcpd program can also be used for services that are marked as
  538. rpc/udp in the inetd configuration file, but not for rpc/tcp services
  539. such as rexd.  You probably do not want to run rexd anyway. On most
  540. systems it is even less secure than a wildcard in /etc/hosts.equiv.
  541.  
  542. With System V.4-style systems, the tcpd program can also handle TLI
  543. services. When TCP/IP or UDP/IP is used underneath TLI, the wrappers
  544. provide the same functions as with socket-based applications. When some
  545. other protocol is used underneath TLI, functionality will be limited
  546. (no remote username lookups, weird network address formats).
  547.  
  548. Decide which services you want to monitor. Move the corresponding
  549. vendor-provided daemon programs to the location specified by the
  550. REAL_DAEMON_DIR constant in the Makefile, and fill the holes with
  551. copies of the tcpd wrapper. That is, one copy of (or link to) the tcpd
  552. program for each service that you want to monitor. For example, to
  553. monitor the use of your finger service:
  554.  
  555.     # mkdir REAL_DAEMON_DIR
  556.     # mv /usr/etc/in.fingerd REAL_DAEMON_DIR
  557.     # cp tcpd /usr/etc/in.fingerd
  558.  
  559. The example applies to SunOS 4. With other UNIX implementations the
  560. network daemons live in /usr/libexec or /usr/sbin, or have no "in."
  561. prefix to their names, but you get the idea.
  562.  
  563. Ultrix only:  If you want to monitor the SYSTAT service, move the
  564. vendor-provided miscd daemon to the location specified by the
  565. REAL_MISCD macro in the Makefile, and install the miscd wrapper into
  566. the original miscd location.
  567.  
  568. In the absence of any access-control tables, the daemon wrappers
  569. will just maintain a record of network connections made to your system.
  570.  
  571. 7.2 - Advanced configuration and installation
  572. ---------------------------------------------
  573.  
  574. The advanced recipe leaves your daemon executables alone, but involves
  575. simple modifications to the inetd configuration file.
  576.  
  577. Copy the file Makefile.dist to Makefile.  In the Makefile, define the
  578. REAL_DAEMON_DIR macro (if you run Ultrix, the REAL_MISCD macro, too) to
  579. reflect the path to your existing network daemons. Don't panic when
  580. some daemons live elsewhere; we'll deal with that later.  Have a look
  581. at the other instructions in the Makefile and type `make'.
  582.  
  583. When the `make' succeeds the result is two executables (maybe three in
  584. case of Ultrix). The `try' program can be used to play with host access
  585. control tables and is described in a later section.
  586.  
  587. The tcpd program can be used to monitor the telnet, finger, ftp, exec,
  588. rsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
  589. a one-to-one mapping onto executable files. 
  590.  
  591. With System V.4-style systems, the tcpd program can also handle TLI
  592. services. When TCP/IP or UDP/IP is used underneath TLI, the wrappers
  593. provide the same functions as with socket-based applications. When some
  594. other protocol is used underneath TLI, functionality will be limited
  595. (no remote username lookups, weird network address formats).
  596.  
  597. The tcpd program can also be used for services that are marked as
  598. rpc/udp in the inetd configuration file, but not for rpc/tcp services
  599. such as rexd.  You probably do not want to run rexd anyway. On most
  600. systems it is even less secure than a wildcard in /etc/hosts.equiv.
  601.  
  602. Install the tcpd command in a suitable place. Apollo UNIX users will
  603. want to install it under a different name because the name "tcpd" is
  604. already taken; a suitable name for the wrapper program would be
  605. "frontd".  Then perform the following edits on the inetd configuration
  606. file (usually /etc/inetd.conf or /etc/inet/inetd.conf):
  607.  
  608.     finger  stream  tcp     nowait  nobody  /usr/etc/in.fingerd     in.fingerd
  609.  
  610. becomes:
  611.  
  612.     finger  stream  tcp     nowait  nobody  /usr/etc/tcpd           in.fingerd
  613.  
  614. Send a `kill -HUP' to the inetd process to make the change effective.
  615.  
  616. The example applies to SunOS 4. With other UNIX implementations the
  617. network daemons live in /usr/libexec or /usr/sbin, the network daemons
  618. have no "in." prefix to their names, or the username field in the inetd
  619. configuration file may be missing.
  620.  
  621. When the finger service works as expected you can perform similar
  622. changes for other network services. Do not forget the `kill -HUP'.
  623.  
  624. The miscd daemon that comes with Ultrix implements several network
  625. services. It decides what to do by looking at its process name. One of
  626. the services is systat, which is a kind of limited finger service.  If
  627. you want to monitor the systat service, install the miscd wrapper in
  628. a suitable place and update the inetd configuration file:
  629.  
  630.     systat  stream  tcp     nowait  /suitable/place/miscd      systatd
  631.  
  632. Ultrix 4.3 allows you to specify a user id under which the daemon will
  633. be executed. This feature is not documented in the manual pages.  Thus,
  634. the example would become:
  635.  
  636.     systat  stream  tcp     nowait  nobody /suitable/place/miscd    systatd
  637.  
  638. Older Ultrix systems still run all their network daemons as root.
  639.  
  640. In the absence of any access-control tables, the daemon wrappers
  641. will just maintain a record of network connections made to your system.
  642.  
  643. 7.3 - Daemons with arbitrary path names
  644. ---------------------------------------
  645.  
  646. The above tcpd examples work fine with network daemons that live in a
  647. common directory, but sometimes that is not practical. Having soft
  648. links all over your file system is not a clean solution, either.
  649.  
  650. Instead you can specify, in the inetd configuration file, an absolute
  651. path name for the daemon process name.  For example,
  652.  
  653.     ntalk   dgram   udp     wait    root    /usr/etc/tcpd /usr/local/lib/ntalkd
  654.  
  655. When the daemon process name is an absolute path name, tcpd ignores the
  656. value of the REAL_DAEMON_DIR constant, and uses the last path component
  657. of the daemon process name for logging and for access control.
  658.  
  659. 7.4 - Building and testing the access control rules
  660. ---------------------------------------------------
  661.  
  662. In order to support access control the wrappers must be compiled with
  663. the -DHOSTS_ACCESS option. The access control policy is given in the
  664. form of two tables (default: /etc/hosts.allow and /etc/hosts.deny).
  665. Access control is disabled when there are no access control tables, or
  666. when the tables are empty.
  667.  
  668. If you haven't used the wrappers before I recommend that you first run
  669. them a couple of days without any access control restrictions. The
  670. logfile records should give you an idea of the process names and of the
  671. host names that you will have to build into your access control rules.
  672.  
  673. The syntax of the access control rules is documented in the file
  674. hosts_access.5, which is in `nroff -man' format. This is a lengthy
  675. document, and no-one expects you to read it right away from beginning
  676. to end.  Instead, after reading the introductory section, skip to the
  677. examples at the end so that you get a general idea of the language.
  678. Then you can appreciate the detailed reference sections near the
  679. beginning of the document.
  680.  
  681. The examples in the hosts_access.5 document show two specific types of
  682. access control policy:  1) mostly closed (only permitting access from a
  683. limited number of systems) and 2) mostly open (permitting access from
  684. everyone except a limited number of trouble makers). You will have to
  685. choose what model suits your situation best. Implementing a mixed
  686. policy should not be overly difficult either.
  687.  
  688. The `try' command can be used to try out your local access control
  689. files.  The command syntax is:
  690.  
  691.     ./try process_name hostname    (e.g.: ./try in.tftpd localhost)
  692.  
  693.     ./try process_name address    (e.g.: ./try in.tftpd 127.0.0.1)
  694.  
  695. In order to find out what process name to use, just use the service and
  696. watch the process name that shows up in the logfile.  Alternatively,
  697. you can look up the name from the inetd configuration file. Coming back
  698. to the tftp example in the tutorial section above:
  699.  
  700.     tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
  701.  
  702. This entry causes the inetd to run the wrapper program (tcpd) with a
  703. process name `in.tftpd'.  This is the name that the wrapper will use
  704. when scanning the access control tables. Therefore, `in.tftpd' is the
  705. process name that should be given to the `try' command. On your system
  706. the actual inetd.conf entry may differ (tftpd instead of in.tftpd, and
  707. no `root' field), but you get the idea.
  708.  
  709. When you specify a host name, the `try' program will use both the host
  710. name and address. This way you can simulate the most common case where
  711. the wrappers know both the host address and the host name.  The `try'
  712. program will iterate over all addresses that it can find for the given
  713. host name.
  714.  
  715. When you specify a host address instead of a host name, the `try'
  716. program will pretend that the host name is unknown, so that you can
  717. simulate what happens when the wrapper is unable to look up the remote
  718. host name.
  719.  
  720. Serious errors in the configuration file syntax will be reported via
  721. the syslog daemon.  Run a `tail -f' on the logfile while playing with
  722. the `try' command. The tutorial section at the beginning of this file
  723. describes where to look for your logfile.
  724.  
  725. 7.5 - Other applications
  726. ------------------------
  727.  
  728. The access control routines can easily be integrated with other
  729. programs.  The hosts_access.3 manual page (`nroff -man' format)
  730. describes the external interface of the libwrap.a library.
  731.  
  732. The tcpd wrapper can even be used to control access to the smtp port.
  733. In that case, sendmail should not be run as a stand-alone daemon, but
  734. it should be registered in the inetd configuration file. For example:
  735.  
  736.     smtp    stream  tcp     nowait  root    /usr/etc/tcpd /usr/lib/sendmail -bs
  737.  
  738. You will periodically want to run sendmail to process queued-up
  739. messages. A crontab entry like:
  740.  
  741.     0,15,30,45 * * * * /usr/lib/sendmail -q
  742.  
  743. should take care of that. When you are going to "protect" your sendmail
  744. daemon this way, you should realize that there are many "unprotected"
  745. sendmail daemons all over the network that can still be abused.
  746.  
  747. 8 - Acknowledgements
  748. --------------------
  749.  
  750. Many people contributed to the evolution of the programs, by asking
  751. inspiring questions, by suggesting features or bugfixes, or by
  752. submitting source code.  Nevertheless, all mistakes and bugs in the
  753. wrappers are my own.
  754.  
  755. Thanks to Brendan Kehoe (brendan@cs.widener.edu), Heimir Sverrisson
  756. (heimir@hafro.is) and Dan Bernstein (brnstnd@kramden.acf.nyu.edu) for
  757. feedback on an early release of this product.  The host name/address
  758. check was suggested by John Kimball (jkimball@src.honeywell.com).
  759. Apollo's UNIX environment has some peculiar quirks: Willem-Jan Withagen
  760. (wjw@eb.ele.tue.nl), Pieter Schoenmakers (tiggr@es.ele.tue.nl) and
  761. Charles S. Fuller (fuller@wccs.psc.edu) provided assistance.  Hal R.
  762. Brand (BRAND@addvax.llnl.gov) told me how to get the remote IP address
  763. in case of datagram-oriented services, and suggested the optional shell
  764. command feature.  Shabbir Safdar (shabby@mentor.cc.purdue.edu) provided
  765. a first version of a much-needed manual page.  Granville Boman Goza, IV
  766. (gbg@sei.cmu.edu) suggested to use the remote IP address even when the
  767. host name is available.  Casper H.S. Dik (casper@fwi.uva.nl) provided
  768. additional insight into DNS spoofing techniques.  The bogus daemon
  769. feature was inspired by code from Andrew Macpherson (BNR Europe Ltd).
  770. Steve Bellovin (smb@research.att.com) confirmed some of my suspicions
  771. about the darker sides of TCP/IP insecurity.
  772.  
  773. In no particular order, Howard Chu (hyc@hanauma.jpl.nasa.gov), John P.
  774. Rouillard (rouilj@cs.umb.edu), Darren Reed (avalon@coombs.anu.edu.au),
  775. Icarus Sparry (I.Sparry@gdr.bath.ac.uk), Scott Schwartz (schwartz@
  776. cs.psu.edu), John A. Kunze (jak@violet.berkeley.edu), Daniel Len
  777. Schales (dan@engr.latech.edu), Chris Turbeville <turbo@cse.uta.edu>,
  778. Paul Kranenburg <pk@cs.few.eur.nl>, and many, many others provided
  779. fixes, code fragments, or other improvements to the wrappers.
  780.  
  781.     Wietse Venema (wietse@wzv.win.tue.nl)
  782.     Department of Mathematics and Computing Science
  783.     Eindhoven University of Technology
  784.     P.O. Box 513
  785.     5600 MB Eindhoven
  786.     The Netherlands
  787.